/*
 * Copyright (C) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "attest_utils_log.h"
#include "attest_error.h"
#include "attest_tls.h"

const unsigned char GLOBALSIGN_ROOT_CA_R3_DER[] = {
    0X30, 0X82, 0X03, 0X5F, 0X30, 0X82, 0X02, 0X47, 0XA0, 0X03, 0X02, 0X01,
    0X02, 0X02, 0X0B, 0X04, 0X00, 0X00, 0X00, 0X00, 0X01, 0X21, 0X58, 0X53,
    0X08, 0XA2, 0X30, 0X0D, 0X06, 0X09, 0X2A, 0X86, 0X48, 0X86, 0XF7, 0X0D,
    0X01, 0X01, 0X0B, 0X05, 0X00, 0X30, 0X4C, 0X31, 0X20, 0X30, 0X1E, 0X06,
    0X03, 0X55, 0X04, 0X0B, 0X13, 0X17, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C,
    0X53, 0X69, 0X67, 0X6E, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X43, 0X41,
    0X20, 0X2D, 0X20, 0X52, 0X33, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55,
    0X04, 0X0A, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69,
    0X67, 0X6E, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55, 0X04, 0X03, 0X13,
    0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X30,
    0X1E, 0X17, 0X0D, 0X30, 0X39, 0X30, 0X33, 0X31, 0X38, 0X31, 0X30, 0X30,
    0X30, 0X30, 0X30, 0X5A, 0X17, 0X0D, 0X32, 0X39, 0X30, 0X33, 0X31, 0X38,
    0X31, 0X30, 0X30, 0X30, 0X30, 0X30, 0X5A, 0X30, 0X4C, 0X31, 0X20, 0X30,
    0X1E, 0X06, 0X03, 0X55, 0X04, 0X0B, 0X13, 0X17, 0X47, 0X6C, 0X6F, 0X62,
    0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20,
    0X43, 0X41, 0X20, 0X2D, 0X20, 0X52, 0X33, 0X31, 0X13, 0X30, 0X11, 0X06,
    0X03, 0X55, 0X04, 0X0A, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C,
    0X53, 0X69, 0X67, 0X6E, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55, 0X04,
    0X03, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67,
    0X6E, 0X30, 0X82, 0X01, 0X22, 0X30, 0X0D, 0X06, 0X09, 0X2A, 0X86, 0X48,
    0X86, 0XF7, 0X0D, 0X01, 0X01, 0X01, 0X05, 0X00, 0X03, 0X82, 0X01, 0X0F,
    0X00, 0X30, 0X82, 0X01, 0X0A, 0X02, 0X82, 0X01, 0X01, 0X00, 0XCC, 0X25,
    0X76, 0X90, 0X79, 0X06, 0X78, 0X22, 0X16, 0XF5, 0XC0, 0X83, 0XB6, 0X84,
    0XCA, 0X28, 0X9E, 0XFD, 0X05, 0X76, 0X11, 0XC5, 0XAD, 0X88, 0X72, 0XFC,
    0X46, 0X02, 0X43, 0XC7, 0XB2, 0X8A, 0X9D, 0X04, 0X5F, 0X24, 0XCB, 0X2E,
    0X4B, 0XE1, 0X60, 0X82, 0X46, 0XE1, 0X52, 0XAB, 0X0C, 0X81, 0X47, 0X70,
    0X6C, 0XDD, 0X64, 0XD1, 0XEB, 0XF5, 0X2C, 0XA3, 0X0F, 0X82, 0X3D, 0X0C,
    0X2B, 0XAE, 0X97, 0XD7, 0XB6, 0X14, 0X86, 0X10, 0X79, 0XBB, 0X3B, 0X13,
    0X80, 0X77, 0X8C, 0X08, 0XE1, 0X49, 0XD2, 0X6A, 0X62, 0X2F, 0X1F, 0X5E,
    0XFA, 0X96, 0X68, 0XDF, 0X89, 0X27, 0X95, 0X38, 0X9F, 0X06, 0XD7, 0X3E,
    0XC9, 0XCB, 0X26, 0X59, 0X0D, 0X73, 0XDE, 0XB0, 0XC8, 0XE9, 0X26, 0X0E,
    0X83, 0X15, 0XC6, 0XEF, 0X5B, 0X8B, 0XD2, 0X04, 0X60, 0XCA, 0X49, 0XA6,
    0X28, 0XF6, 0X69, 0X3B, 0XF6, 0XCB, 0XC8, 0X28, 0X91, 0XE5, 0X9D, 0X8A,
    0X61, 0X57, 0X37, 0XAC, 0X74, 0X14, 0XDC, 0X74, 0XE0, 0X3A, 0XEE, 0X72,
    0X2F, 0X2E, 0X9C, 0XFB, 0XD0, 0XBB, 0XBF, 0XF5, 0X3D, 0X00, 0XE1, 0X06,
    0X33, 0XE8, 0X82, 0X2B, 0XAE, 0X53, 0XA6, 0X3A, 0X16, 0X73, 0X8C, 0XDD,
    0X41, 0X0E, 0X20, 0X3A, 0XC0, 0XB4, 0XA7, 0XA1, 0XE9, 0XB2, 0X4F, 0X90,
    0X2E, 0X32, 0X60, 0XE9, 0X57, 0XCB, 0XB9, 0X04, 0X92, 0X68, 0X68, 0XE5,
    0X38, 0X26, 0X60, 0X75, 0XB2, 0X9F, 0X77, 0XFF, 0X91, 0X14, 0XEF, 0XAE,
    0X20, 0X49, 0XFC, 0XAD, 0X40, 0X15, 0X48, 0XD1, 0X02, 0X31, 0X61, 0X19,
    0X5E, 0XB8, 0X97, 0XEF, 0XAD, 0X77, 0XB7, 0X64, 0X9A, 0X7A, 0XBF, 0X5F,
    0XC1, 0X13, 0XEF, 0X9B, 0X62, 0XFB, 0X0D, 0X6C, 0XE0, 0X54, 0X69, 0X16,
    0XA9, 0X03, 0XDA, 0X6E, 0XE9, 0X83, 0X93, 0X71, 0X76, 0XC6, 0X69, 0X85,
    0X82, 0X17, 0X02, 0X03, 0X01, 0X00, 0X01, 0XA3, 0X42, 0X30, 0X40, 0X30,
    0X0E, 0X06, 0X03, 0X55, 0X1D, 0X0F, 0X01, 0X01, 0XFF, 0X04, 0X04, 0X03,
    0X02, 0X01, 0X06, 0X30, 0X0F, 0X06, 0X03, 0X55, 0X1D, 0X13, 0X01, 0X01,
    0XFF, 0X04, 0X05, 0X30, 0X03, 0X01, 0X01, 0XFF, 0X30, 0X1D, 0X06, 0X03,
    0X55, 0X1D, 0X0E, 0X04, 0X16, 0X04, 0X14, 0X8F, 0XF0, 0X4B, 0X7F, 0XA8,
    0X2E, 0X45, 0X24, 0XAE, 0X4D, 0X50, 0XFA, 0X63, 0X9A, 0X8B, 0XDE, 0XE2,
    0XDD, 0X1B, 0XBC, 0X30, 0X0D, 0X06, 0X09, 0X2A, 0X86, 0X48, 0X86, 0XF7,
    0X0D, 0X01, 0X01, 0X0B, 0X05, 0X00, 0X03, 0X82, 0X01, 0X01, 0X00, 0X4B,
    0X40, 0XDB, 0XC0, 0X50, 0XAA, 0XFE, 0XC8, 0X0C, 0XEF, 0XF7, 0X96, 0X54,
    0X45, 0X49, 0XBB, 0X96, 0X00, 0X09, 0X41, 0XAC, 0XB3, 0X13, 0X86, 0X86,
    0X28, 0X07, 0X33, 0XCA, 0X6B, 0XE6, 0X74, 0XB9, 0XBA, 0X00, 0X2D, 0XAE,
    0XA4, 0X0A, 0XD3, 0XF5, 0XF1, 0XF1, 0X0F, 0X8A, 0XBF, 0X73, 0X67, 0X4A,
    0X83, 0XC7, 0X44, 0X7B, 0X78, 0XE0, 0XAF, 0X6E, 0X6C, 0X6F, 0X03, 0X29,
    0X8E, 0X33, 0X39, 0X45, 0XC3, 0X8E, 0XE4, 0XB9, 0X57, 0X6C, 0XAA, 0XFC,
    0X12, 0X96, 0XEC, 0X53, 0XC6, 0X2D, 0XE4, 0X24, 0X6C, 0XB9, 0X94, 0X63,
    0XFB, 0XDC, 0X53, 0X68, 0X67, 0X56, 0X3E, 0X83, 0XB8, 0XCF, 0X35, 0X21,
    0XC3, 0XC9, 0X68, 0XFE, 0XCE, 0XDA, 0XC2, 0X53, 0XAA, 0XCC, 0X90, 0X8A,
    0XE9, 0XF0, 0X5D, 0X46, 0X8C, 0X95, 0XDD, 0X7A, 0X58, 0X28, 0X1A, 0X2F,
    0X1D, 0XDE, 0XCD, 0X00, 0X37, 0X41, 0X8F, 0XED, 0X44, 0X6D, 0XD7, 0X53,
    0X28, 0X97, 0X7E, 0XF3, 0X67, 0X04, 0X1E, 0X15, 0XD7, 0X8A, 0X96, 0XB4,
    0XD3, 0XDE, 0X4C, 0X27, 0XA4, 0X4C, 0X1B, 0X73, 0X73, 0X76, 0XF4, 0X17,
    0X99, 0XC2, 0X1F, 0X7A, 0X0E, 0XE3, 0X2D, 0X08, 0XAD, 0X0A, 0X1C, 0X2C,
    0XFF, 0X3C, 0XAB, 0X55, 0X0E, 0X0F, 0X91, 0X7E, 0X36, 0XEB, 0XC3, 0X57,
    0X49, 0XBE, 0XE1, 0X2E, 0X2D, 0X7C, 0X60, 0X8B, 0XC3, 0X41, 0X51, 0X13,
    0X23, 0X9D, 0XCE, 0XF7, 0X32, 0X6B, 0X94, 0X01, 0XA8, 0X99, 0XE7, 0X2C,
    0X33, 0X1F, 0X3A, 0X3B, 0X25, 0XD2, 0X86, 0X40, 0XCE, 0X3B, 0X2C, 0X86,
    0X78, 0XC9, 0X61, 0X2F, 0X14, 0XBA, 0XEE, 0XDB, 0X55, 0X6F, 0XDF, 0X84,
    0XEE, 0X05, 0X09, 0X4D, 0XBD, 0X28, 0XD8, 0X72, 0XCE, 0XD3, 0X62, 0X50,
    0X65, 0X1E, 0XEB, 0X92, 0X97, 0X83, 0X31, 0XD9, 0XB3, 0XB5, 0XCA, 0X47,
    0X58, 0X3F, 0X5F
};

const unsigned char GLOBALSIGN_ECC_ROOT_CA_DER[] = {
    0X30, 0X82, 0X02, 0X1E, 0X30, 0X82, 0X01, 0XA4, 0XA0, 0X03, 0X02, 0X01,
    0X02, 0X02, 0X11, 0X60, 0X59, 0X49, 0XE0, 0X26, 0X2E, 0XBB, 0X55, 0XF9,
    0X0A, 0X77, 0X8A, 0X71, 0XF9, 0X4A, 0XD8, 0X6C, 0X30, 0X0A, 0X06, 0X08,
    0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X30, 0X50, 0X31, 0X24,
    0X30, 0X22, 0X06, 0X03, 0X55, 0X04, 0X0B, 0X13, 0X1B, 0X47, 0X6C, 0X6F,
    0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X45, 0X43, 0X43, 0X20,
    0X52, 0X6F, 0X6F, 0X74, 0X20, 0X43, 0X41, 0X20, 0X2D, 0X20, 0X52, 0X35,
    0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X0A, 0X47,
    0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X31, 0X13, 0X30,
    0X11, 0X06, 0X03, 0X55, 0X04, 0X03, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62,
    0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X30, 0X1E, 0X17, 0X0D, 0X31, 0X32,
    0X31, 0X31, 0X31, 0X33, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30, 0X5A, 0X17,
    0X0D, 0X33, 0X38, 0X30, 0X31, 0X31, 0X39, 0X30, 0X33, 0X31, 0X34, 0X30,
    0X37, 0X5A, 0X30, 0X50, 0X31, 0X24, 0X30, 0X22, 0X06, 0X03, 0X55, 0X04,
    0X0B, 0X13, 0X1B, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67,
    0X6E, 0X20, 0X45, 0X43, 0X43, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X43,
    0X41, 0X20, 0X2D, 0X20, 0X52, 0X35, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03,
    0X55, 0X04, 0X0A, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53,
    0X69, 0X67, 0X6E, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55, 0X04, 0X03,
    0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E,
    0X30, 0X76, 0X30, 0X10, 0X06, 0X07, 0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X02,
    0X01, 0X06, 0X05, 0X2B, 0X81, 0X04, 0X00, 0X22, 0X03, 0X62, 0X00, 0X04,
    0X47, 0X45, 0X0E, 0X96, 0XFB, 0X7D, 0X5D, 0XBF, 0XE9, 0X39, 0XD1, 0X21,
    0XF8, 0X9F, 0X0B, 0XB6, 0XD5, 0X7B, 0X1E, 0X92, 0X3A, 0X48, 0X59, 0X1C,
    0XF0, 0X62, 0X31, 0X2D, 0XC0, 0X7A, 0X28, 0XFE, 0X1A, 0XA7, 0X5C, 0XB3,
    0XB6, 0XCC, 0X97, 0XE7, 0X45, 0XD4, 0X58, 0XFA, 0XD1, 0X77, 0X6D, 0X43,
    0XA2, 0XC0, 0X87, 0X65, 0X34, 0X0A, 0X1F, 0X7A, 0XDD, 0XEB, 0X3C, 0X33,
    0XA1, 0XC5, 0X9D, 0X4D, 0XA4, 0X6F, 0X41, 0X95, 0X38, 0X7F, 0XC9, 0X1E,
    0X84, 0XEB, 0XD1, 0X9E, 0X49, 0X92, 0X87, 0X94, 0X87, 0X0C, 0X3A, 0X85,
    0X4A, 0X66, 0X9F, 0X9D, 0X59, 0X93, 0X4D, 0X97, 0X61, 0X06, 0X86, 0X4A,
    0XA3, 0X42, 0X30, 0X40, 0X30, 0X0E, 0X06, 0X03, 0X55, 0X1D, 0X0F, 0X01,
    0X01, 0XFF, 0X04, 0X04, 0X03, 0X02, 0X01, 0X06, 0X30, 0X0F, 0X06, 0X03,
    0X55, 0X1D, 0X13, 0X01, 0X01, 0XFF, 0X04, 0X05, 0X30, 0X03, 0X01, 0X01,
    0XFF, 0X30, 0X1D, 0X06, 0X03, 0X55, 0X1D, 0X0E, 0X04, 0X16, 0X04, 0X14,
    0X3D, 0XE6, 0X29, 0X48, 0X9B, 0XEA, 0X07, 0XCA, 0X21, 0X44, 0X4A, 0X26,
    0XDE, 0X6E, 0XDE, 0XD2, 0X83, 0XD0, 0X9F, 0X59, 0X30, 0X0A, 0X06, 0X08,
    0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X03, 0X68, 0X00, 0X30,
    0X65, 0X02, 0X31, 0X00, 0XE5, 0X69, 0X12, 0XC9, 0X6E, 0XDB, 0XC6, 0X31,
    0XBA, 0X09, 0X41, 0XE1, 0X97, 0XF8, 0XFB, 0XFD, 0X9A, 0XE2, 0X7D, 0X12,
    0XC9, 0XED, 0X7C, 0X64, 0XD3, 0XCB, 0X05, 0X25, 0X8B, 0X56, 0XD9, 0XA0,
    0XE7, 0X5E, 0X5D, 0X4E, 0X0B, 0X83, 0X9C, 0X5B, 0X76, 0X29, 0XA0, 0X09,
    0X26, 0X21, 0X6A, 0X62, 0X02, 0X30, 0X71, 0XD2, 0XB5, 0X8F, 0X5C, 0XEA,
    0X3B, 0XE1, 0X78, 0X09, 0X85, 0XA8, 0X75, 0X92, 0X3B, 0XC8, 0X5C, 0XFD,
    0X48, 0XEF, 0X0D, 0X74, 0X22, 0XA8, 0X08, 0XE2, 0X6E, 0XC5, 0X49, 0XCE,
    0XC7, 0X0C, 0XBC, 0XA7, 0X61, 0X69, 0XF1, 0XF7, 0X3B, 0XE1, 0X2A, 0XCB,
    0XF9, 0X2B, 0XF3, 0X66, 0X90, 0X37
};

const unsigned char E46_GLOBALSIGN_ROOT_CA_DER[] = {
    0X30, 0X82, 0X02, 0X0B, 0X30, 0X82, 0X01, 0X91, 0XA0, 0X03, 0X02, 0X01,
    0X02, 0X02, 0X12, 0X11, 0XD2, 0XBB, 0XBA, 0X33, 0X6E, 0XD4, 0XBC, 0XE6,
    0X24, 0X68, 0XC5, 0X0D, 0X84, 0X1D, 0X98, 0XE8, 0X43, 0X30, 0X0A, 0X06,
    0X08, 0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X30, 0X46, 0X31,
    0X0B, 0X30, 0X09, 0X06, 0X03, 0X55, 0X04, 0X06, 0X13, 0X02, 0X42, 0X45,
    0X31, 0X19, 0X30, 0X17, 0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X10, 0X47,
    0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X6E, 0X76,
    0X2D, 0X73, 0X61, 0X31, 0X1C, 0X30, 0X1A, 0X06, 0X03, 0X55, 0X04, 0X03,
    0X13, 0X13, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E,
    0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X45, 0X34, 0X36, 0X30, 0X1E, 0X17,
    0X0D, 0X31, 0X39, 0X30, 0X33, 0X32, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30,
    0X30, 0X5A, 0X17, 0X0D, 0X34, 0X36, 0X30, 0X33, 0X32, 0X30, 0X30, 0X30,
    0X30, 0X30, 0X30, 0X30, 0X5A, 0X30, 0X46, 0X31, 0X0B, 0X30, 0X09, 0X06,
    0X03, 0X55, 0X04, 0X06, 0X13, 0X02, 0X42, 0X45, 0X31, 0X19, 0X30, 0X17,
    0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X10, 0X47, 0X6C, 0X6F, 0X62, 0X61,
    0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X6E, 0X76, 0X2D, 0X73, 0X61, 0X31,
    0X1C, 0X30, 0X1A, 0X06, 0X03, 0X55, 0X04, 0X03, 0X13, 0X13, 0X47, 0X6C,
    0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X52, 0X6F, 0X6F,
    0X74, 0X20, 0X45, 0X34, 0X36, 0X30, 0X76, 0X30, 0X10, 0X06, 0X07, 0X2A,
    0X86, 0X48, 0XCE, 0X3D, 0X02, 0X01, 0X06, 0X05, 0X2B, 0X81, 0X04, 0X00,
    0X22, 0X03, 0X62, 0X00, 0X04, 0X9C, 0X0E, 0XB1, 0XCF, 0XB7, 0XE8, 0X9E,
    0X52, 0X77, 0X75, 0X34, 0XFA, 0XA5, 0X46, 0XA7, 0XAD, 0X32, 0X19, 0X32,
    0XB4, 0X07, 0XA9, 0X27, 0XCA, 0X94, 0XBB, 0X0C, 0XD2, 0X0A, 0X10, 0XC7,
    0XDA, 0X89, 0XB0, 0X97, 0X0C, 0X70, 0X13, 0X09, 0X01, 0X8E, 0XD8, 0XEA,
    0X47, 0XEA, 0XBE, 0XB2, 0X80, 0X2B, 0XCD, 0XFC, 0X28, 0X0D, 0XDB, 0XAC,
    0XBC, 0XA4, 0X86, 0X37, 0XED, 0X70, 0X08, 0X00, 0X75, 0XEA, 0X93, 0X0B,
    0X7B, 0X2E, 0X52, 0X9C, 0X23, 0X68, 0X23, 0X06, 0X43, 0XEC, 0X92, 0X2F,
    0X53, 0X84, 0XDB, 0XFB, 0X47, 0X14, 0X07, 0XE8, 0X5F, 0X94, 0X67, 0X5D,
    0XC9, 0X7A, 0X81, 0X3C, 0X20, 0XA3, 0X42, 0X30, 0X40, 0X30, 0X0E, 0X06,
    0X03, 0X55, 0X1D, 0X0F, 0X01, 0X01, 0XFF, 0X04, 0X04, 0X03, 0X02, 0X01,
    0X86, 0X30, 0X0F, 0X06, 0X03, 0X55, 0X1D, 0X13, 0X01, 0X01, 0XFF, 0X04,
    0X05, 0X30, 0X03, 0X01, 0X01, 0XFF, 0X30, 0X1D, 0X06, 0X03, 0X55, 0X1D,
    0X0E, 0X04, 0X16, 0X04, 0X14, 0X31, 0X0A, 0X90, 0X8F, 0XB6, 0XC6, 0X9D,
    0XD2, 0X44, 0X4B, 0X80, 0XB5, 0XA2, 0XE6, 0X1F, 0XB1, 0X12, 0X4F, 0X1B,
    0X95, 0X30, 0X0A, 0X06, 0X08, 0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03,
    0X03, 0X03, 0X68, 0X00, 0X30, 0X65, 0X02, 0X31, 0X00, 0XDF, 0X54, 0X90,
    0XED, 0X9B, 0XEF, 0X8B, 0X94, 0X02, 0X93, 0X17, 0X82, 0X99, 0XBE, 0XB3,
    0X9E, 0X2C, 0XF6, 0X0B, 0X91, 0X8C, 0X9F, 0X4A, 0X14, 0XB1, 0XF6, 0X64,
    0XBC, 0XBB, 0X68, 0X51, 0X13, 0X0C, 0X03, 0XF7, 0X15, 0X8B, 0X84, 0X60,
    0XB9, 0X8B, 0XFF, 0X52, 0X8E, 0XE7, 0X8C, 0XBC, 0X1C, 0X02, 0X30, 0X3C,
    0XF9, 0X11, 0XD4, 0X8C, 0X4E, 0XC0, 0XC1, 0X61, 0XC2, 0X15, 0X4C, 0XAA,
    0XAB, 0X1D, 0X0B, 0X31, 0X5F, 0X3B, 0X1C, 0XE2, 0X00, 0X97, 0X44, 0X31,
    0XE6, 0XFE, 0X73, 0X96, 0X2F, 0XDA, 0X96, 0XD3, 0XFE, 0X08, 0X07, 0XB3,
    0X34, 0X89, 0XBC, 0X05, 0X9F, 0XF7, 0X1E, 0X86, 0XEE, 0X8B, 0X70
};

const unsigned char GLOBALSIGN_IOT_ROOT_E60_DER[] = {
    0X30, 0X82, 0X02, 0X13, 0X30, 0X82, 0X01, 0X99, 0XA0, 0X03, 0X02, 0X01,
    0X02, 0X02, 0X10, 0X76, 0X53, 0XFE, 0XB5, 0X6A, 0XC8, 0XEE, 0X4E, 0X8A,
    0XC6, 0XFE, 0X5E, 0X9E, 0X38, 0XF5, 0XEB, 0X30, 0X0A, 0X06, 0X08, 0X2A,
    0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X30, 0X4A, 0X31, 0X0B, 0X30,
    0X09, 0X06, 0X03, 0X55, 0X04, 0X06, 0X13, 0X02, 0X42, 0X45, 0X31, 0X19,
    0X30, 0X17, 0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X10, 0X47, 0X6C, 0X6F,
    0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X6E, 0X76, 0X2D, 0X73,
    0X61, 0X31, 0X20, 0X30, 0X1E, 0X06, 0X03, 0X55, 0X04, 0X03, 0X13, 0X17,
    0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X49,
    0X6F, 0X54, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X45, 0X36, 0X30, 0X30,
    0X20, 0X17, 0X0D, 0X32, 0X30, 0X30, 0X33, 0X31, 0X38, 0X30, 0X30, 0X30,
    0X30, 0X30, 0X30, 0X5A, 0X18, 0X0F, 0X32, 0X30, 0X36, 0X30, 0X30, 0X33,
    0X31, 0X38, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30, 0X5A, 0X30, 0X4A, 0X31,
    0X0B, 0X30, 0X09, 0X06, 0X03, 0X55, 0X04, 0X06, 0X13, 0X02, 0X42, 0X45,
    0X31, 0X19, 0X30, 0X17, 0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X10, 0X47,
    0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X6E, 0X76,
    0X2D, 0X73, 0X61, 0X31, 0X20, 0X30, 0X1E, 0X06, 0X03, 0X55, 0X04, 0X03,
    0X13, 0X17, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E,
    0X20, 0X49, 0X6F, 0X54, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X45, 0X36,
    0X30, 0X30, 0X76, 0X30, 0X10, 0X06, 0X07, 0X2A, 0X86, 0X48, 0XCE, 0X3D,
    0X02, 0X01, 0X06, 0X05, 0X2B, 0X81, 0X04, 0X00, 0X22, 0X03, 0X62, 0X00,
    0X04, 0XCA, 0X9E, 0X91, 0X00, 0X0F, 0X0D, 0XA0, 0XCE, 0X23, 0X36, 0XF7,
    0X8F, 0X55, 0X8F, 0X8C, 0XAF, 0X26, 0X1B, 0X1A, 0X6B, 0XEF, 0XD1, 0X29,
    0XE6, 0X14, 0X50, 0XD7, 0XC4, 0X00, 0XD2, 0X71, 0X99, 0X25, 0XF5, 0XF5,
    0X0C, 0X1D, 0X0E, 0X70, 0X09, 0XC0, 0XAF, 0X13, 0XB4, 0X69, 0X03, 0X48,
    0X04, 0XAC, 0XB4, 0X61, 0X6B, 0XB6, 0X95, 0XEF, 0XA8, 0X48, 0X6E, 0XEA,
    0XBD, 0X50, 0XD4, 0X74, 0X12, 0XA9, 0XA2, 0X37, 0X9C, 0X1C, 0XBA, 0X59,
    0X7C, 0X17, 0X6F, 0XFC, 0XDA, 0X7F, 0XC1, 0XE2, 0XA5, 0X1D, 0X66, 0X6E,
    0X83, 0X6D, 0X4C, 0X68, 0XE9, 0X82, 0XCE, 0XC1, 0X70, 0X88, 0X24, 0X7D,
    0X60, 0XA3, 0X42, 0X30, 0X40, 0X30, 0X0E, 0X06, 0X03, 0X55, 0X1D, 0X0F,
    0X01, 0X01, 0XFF, 0X04, 0X04, 0X03, 0X02, 0X01, 0X86, 0X30, 0X0F, 0X06,
    0X03, 0X55, 0X1D, 0X13, 0X01, 0X01, 0XFF, 0X04, 0X05, 0X30, 0X03, 0X01,
    0X01, 0XFF, 0X30, 0X1D, 0X06, 0X03, 0X55, 0X1D, 0X0E, 0X04, 0X16, 0X04,
    0X14, 0X8C, 0X93, 0XF0, 0X1E, 0X2C, 0XF5, 0XD4, 0X8C, 0X59, 0X1D, 0XBF,
    0X6C, 0XCA, 0X15, 0X8F, 0X32, 0X64, 0X16, 0XF7, 0X86, 0X30, 0X0A, 0X06,
    0X08, 0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X03, 0X68, 0X00,
    0X30, 0X65, 0X02, 0X31, 0X00, 0XA9, 0X0A, 0X77, 0X06, 0XED, 0XE2, 0XAD,
    0X94, 0X65, 0X5F, 0X2A, 0XB5, 0XE2, 0X49, 0XD1, 0XF7, 0XA8, 0X94, 0X86,
    0X9B, 0X48, 0X8B, 0XDB, 0XE2, 0XF1, 0XF9, 0XD7, 0XE8, 0X75, 0X11, 0X99,
    0X94, 0XBD, 0XD8, 0X9F, 0XC6, 0X4E, 0XC5, 0XE8, 0XEB, 0X7B, 0X4F, 0X78,
    0XD8, 0XD3, 0X77, 0X55, 0X56, 0X02, 0X30, 0X37, 0X46, 0X36, 0X39, 0X4C,
    0XED, 0X02, 0X9F, 0XF1, 0X9C, 0X17, 0X5F, 0XA7, 0XB2, 0XE9, 0XBA, 0X24,
    0X56, 0XD5, 0XE3, 0XB1, 0XE3, 0XDE, 0X84, 0XAA, 0XD9, 0X02, 0X0D, 0X8F,
    0X56, 0X64, 0X01, 0X61, 0X6E, 0X81, 0X34, 0X6D, 0X9F, 0X4C, 0XBD, 0X10,
    0X4E, 0XEB, 0XE3, 0X57, 0XC0, 0X36, 0X55
};

CertItem g_commonCerts = {
    .certDer = GLOBALSIGN_ECC_ROOT_CA_DER,
    .certLen = sizeof(GLOBALSIGN_ECC_ROOT_CA_DER)
};

CertItem g_commonOtherCert[] = {
    {
        .certDer = GLOBALSIGN_ROOT_CA_R3_DER,
        .certLen = sizeof(GLOBALSIGN_ROOT_CA_R3_DER)
    }
};

int32_t LoadCommonCert(mbedtls_x509_crt* chain)
{
    if (chain == NULL) {
        ATTEST_LOG_ERROR("[LoadCommonCert] Invalid parameter");
        return ERR_NET_PARSE_CERT_FAIL;
    }
    int32_t ret = mbedtls_x509_crt_parse_der(chain, g_commonCerts.certDer, g_commonCerts.certLen);
    if (ret < 0) {
        ATTEST_LOG_ERROR("[LoadCommonCert] Parse x509 certificate failed, ret = -0x%x", -ret);
        return ERR_NET_PARSE_CERT_FAIL;
    }
    return ATTEST_OK;
}

int32_t LoadCommonOtherCert(mbedtls_x509_crt* chain, uint32_t cursor)
{
    if (chain == NULL || cursor >= ATTEST_ARRAY_SIZE(g_commonOtherCert)) {
        ATTEST_LOG_ERROR("[LoadCommonOtherCert] Invalid parameter");
        return ERR_NET_PARSE_CERT_FAIL;
    }
    int32_t ret = mbedtls_x509_crt_parse_der(chain, g_commonOtherCert[cursor].certDer,
                                             g_commonOtherCert[cursor].certLen);
    if (ret < 0) {
        ATTEST_LOG_ERROR("[LoadCommonOtherCert] Parse x509 certificate failed, ret = -0x%x", -ret);
        return ERR_NET_PARSE_CERT_FAIL;
    }
    return ATTEST_OK;
}

int32_t GetCommonCertSize(void)
{
    return ATTEST_ARRAY_SIZE(g_commonOtherCert);
}